package com.sd.view;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.sd.activity.R;

public class ViewUtil {

	
	public static View getAccountView(Context context,String account,String value){
		
		LayoutInflater mLayoutInflater = LayoutInflater.from(context);
		View convertView = mLayoutInflater.inflate(R.layout.account_view, null);
		TextView accountTV = (TextView)convertView.findViewById(R.id.account);
		String str1 = context.getResources().getString(R.string.str_account);
		accountTV.setText(String.format(str1, account));
		
		TextView accountValueTV = (TextView)convertView.findViewById(R.id.account_value);
		String str2 = String.format(context.getResources().getString(R.string.str_account_amnout), value);
		
		SpannableStringBuilder style=new SpannableStringBuilder(str2); 
		int start = str2.indexOf("：");
		int end = str2.indexOf("点");
		style.setSpan(new ForegroundColorSpan(Color.RED), start+1, end, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
		accountValueTV.setText(style);
		convertView.setVisibility(View.GONE);
		return convertView;
	}
	
	public static View getWarmTips(Context context,int textId){
		TextView text = new TextView(context);
		text.setTextColor(0xff000000);
		String str = context.getResources().getString(textId);
		SpannableStringBuilder style=new SpannableStringBuilder(str); 
		int start1 = str.indexOf("温馨提示");
		int end = str.indexOf("本站币");
		style.setSpan(new ForegroundColorSpan(Color.RED), start1+4, end+3, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
		style.setSpan(new StyleSpan(Typeface.BOLD), 0, start1+4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
		text.setText(style);
		return text;
	}
}
